#include <atomic>
#include <iostream>
#include <memory>

#include "curl_util.h"
#include "download.h"
#include "thread_pool.h"
#include "util.h"

void callback(int data) { logDebug("%d", data); }

int main()
{
    EnvironmentInitializer::instance();
    // std::cout << "input your url" << std::endl;
    std::string url = "http://127.0.0.1:8080/dummy_file.bin";
    // std::cin >> url;

    ThreadPool downloadPool(4), wrieteDiskPool(1);
    std::unique_ptr<Downloader> download = Downloader::create(url, downloadPool, wrieteDiskPool);
    const error_t ret = download->work(url, "output.bin");

    downloadPool.waitAll();
    wrieteDiskPool.waitAll();

    logDebug("download finish and ret: %d", ret);

    return 0;
}